#!/bin/bash

if [ $# -lt 1 ]; then
	echo "Usage: $0 dir [start_chapter]"
	exit
fi

dir=$1
start_chapter=000
[ $# -gt 1 ] && start_chapter=$2


cd $dir

subdirs=`find -type d ! -path . -printf "%f\n" |sort`

for d in $subdirs
do
	if [ $d -lt $start_chapter ]; then
		continue
	fi

	cd $d
	zip $d.zip *
	mv $d.zip ..
	cd ..
done
